package dk.nineconsult.jmoller;

import org.eclipse.xtext.common.types.JvmFeature;
import org.eclipse.xtext.common.types.JvmIdentifyableElement;

import dk.nineconsult.jmoller.mapr.mapr.MappingModule;

public class StringUtils {

	final static public String packageName(MappingModule module) {
		String fqName = module.getModuleName();
		return fqName.substring(0, fqName.lastIndexOf('.'));
	}
	
	final static public String className(MappingModule module) {
		String fqName = module.getModuleName();
		return fqName.substring(fqName.lastIndexOf('.')+1);
	}

	final static public String leafName(JvmIdentifyableElement element) {
		String fqName = element.getCanonicalName();
		return fqName.substring(fqName.lastIndexOf('.')+1);
	}

	final static public String getterName(JvmFeature feature) {
		return "get"+feature.getSimpleName().substring(3);
	}

	final static public String setterName(JvmFeature feature) {
		return "set"+feature.getSimpleName().substring(3);
	}
}
